import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2023-11-30
 * Time: 15:05
 */
public class Test {
    public static void main(String[] args) {
        List<Integer> list2 = new ArrayList<>(5);
        list2.add(1);
        list2.add(2);
        list2.add(3);
        list2.add(4);
        list2.add(5);
        System.out.println("foreach循环下：");
        for (Integer integer:list2) {
            System.out.print(integer+" ");
        }
    }
    public static void main3(String[] args) {
        List<Integer> list2 = new ArrayList<>(5);
        list2.add(1);
        list2.add(2);
        list2.add(3);
        list2.add(4);
        list2.add(5);
        for (int i = 0; i < list2.size(); i++) {
            System.out.print(list2.get(i)+" ");
        }
    }
    public static void main2(String[] args) {
        List<Integer> list2 = new ArrayList<>(5);
        list2.add(1);
        list2.add(2);
        list2.add(3);
        list2.add(4);
        list2.add(5);
        System.out.println(list2);
        System.out.println("在1下标中插入6：");
        list2.add(1,6);
        System.out.println(list2);
        System.out.println("删除下标为2的数：");
        list2.remove(2);
        System.out.println(list2);
        System.out.println("获取下标为3的数");
        System.out.println(list2.get(3));
    }
    public static void main1(String[] args) {
       My_SingleList myLinkedList = new My_SingleList();
       //创建一个链表
       //myLinkedList.createList();
       //头插法
        /*myLinkedList.addFirst(44);
        myLinkedList.addFirst(33);
        myLinkedList.addFirst(22);
        myLinkedList.addFirst(11);
        myLinkedList.display();*/
        //尾插法
        myLinkedList.addLast(11);
        myLinkedList.addLast(22);
        myLinkedList.addLast(33);
        myLinkedList.addLast(44);
        myLinkedList.addLast(55);
     /*   System.out.println("插入前：");
        myLinkedList.display();
        myLinkedList.addIndex(5,66);
        System.out.println("插入后：");
        myLinkedList.display();*/
        /*System.out.println("删除key之前:");
        myLinkedList.display();
        //myLinkedList.remove(22);
        System.out.println("删除key之后:");
        myLinkedList.display();*/
       /* myLinkedList.removeAllKeyCirculate(11);
        System.out.println("删除全部key:");
        myLinkedList.display();*/
        myLinkedList.removeAllKeye(11);
        System.out.println("删除全部key:");
        myLinkedList.display();
        //System.out.println(myLinkedList.contains(66));
    }
}
